package com.mxl.service.channel.strategy.impl;

import java.math.BigDecimal;

import com.mxl.common.DESUtils;
import com.mxl.dao.channel.model.DealRequest;
import com.mxl.service.channel.strategy.ChannelRequestStrategy;

/**
 * 19pay的key
 * 
 * @author xianglin.mo
 * 
 */

public class Pay19ChannelRequestStrategy implements ChannelRequestStrategy {

	private String key;

	/**
	 * 处理卡号卡密加密 和 金额
	 */
	public void handleRequest(DealRequest request) {
		request.setRequestAmount((new BigDecimal(request.getRequestAmount())
				.divide(new BigDecimal(100))).longValue());
		request.setCardNo(DESUtils.encrypt(request.getCardNo(), key)
				.toUpperCase());
		request.setCardPwd(DESUtils.encrypt(request.getCardPwd(), key)
				.toUpperCase());
	}

	public void setKey(String key) {
		this.key = key;
	}

}
